********************************************************************************************************************
*****Do-file for Tables 3-5, A1-4 and A10
*****Who is mobilized to vote by short text messages? Evidence from a nationwide field experiment with young voters
********************************************************************************************************************
*****Last edited 24/6/5
********************************************************************************************************************
*****Ado packages needed: estout
********************************************************************************************************************

clear all

*Programs to calculate group differences with standard errors and stars
capture program drop, myrepost
program myrepost, eclass
ereturn repost b=`1'
ereturn repost V=`2'
ereturn scalar df_r=`3'
end

capture program drop mystars
program mystars, eclass
local d_stars=string(`1', "%9.3f")
local pval=ttail(`3',abs(`1'/`2'))*2

if `pval'<=0.01 {
local d_stars="`d_stars'"+"***"		
}

if `pval'>0.01 & `pval'<=0.05  {
local d_stars="`d_stars'"+"**"		
}

if `pval'>0.05 & `pval'<=0.1  {
local d_stars="`d_stars'"+"*"		
}

local se_stars=string(`2', "%9.3f")

local se_stars="("+"`se_stars'"+")"

ereturn local d_stars="`d_stars'"
ereturn local se_stars="`se_stars'"


end

*Use data
use \data\dataforanalysis230522_v2.dta, clear
*Set basecategory
fvset base 8 moses1d
*Create variable for rural/urban municipality
destring kuntaryhm, replace
gen rural=kuntaryhm==3 if kuntaryhm!=.
replace rural=. if shrereg==.


label variable treated "Treatments Pooled"
label variable treated1 "Neutral Treatment"
label variable treated2 "Expressive Treatment"
label variable treated3 "Informative Treatment"





*************************************************
*****TABLE 3
*************************************************
eststo clear
eststo M1: reg voted22 treated, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M1
eststo M2: reg voted22 treated molincome female age foreign, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income"
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M2
eststo M3:  reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M3
eststo M4:  reg voted22 treated i.kunta19, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M4
eststo M5:  reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool i.kunta19, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M5
local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local numbers "& (1) & (2) & (3) & (4) & (5) \\ \hline"
local emptyrow "& & & & &  \\ "
local line "& & & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("Controls Controls" "Controls1 \phantom{controls}"  "Controls2 \phantom{controls}" "Controls3 \phantom{controls}" "Controls4 \phantom{controls}"  "Controls5 Municipality FE" "umean Untreated $\bar{Y}$" "N Observations") ///
sfmt(%9.3f %9.3f %9.3f %9.3f  %9.3f  %9.3f  %9.3f %9.0fc) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" "`numbers'" "`emptyrow'") ///
refcat(treated "", nolabel below) title("Average Treatment Effect") nonotes replace



*************************************************
*****TABLE A1
*************************************************


eststo clear
eststo M1: logit voted22 treated, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M1
eststo M2: logit voted22 treated molincome female age foreign, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income"
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M2
eststo M3:  logit voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M3
eststo M4:  logit voted22 treated i.kunta19, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M4
eststo M5:  logit voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool i.kunta19, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treated==0
estadd scalar umean=r(table)[1,1]: M5
local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local numbers "& (1) & (2) & (3) & (4) & (5) \\ \hline"
local emptyrow "& & & & &  \\ "
local line "& & & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("Controls Controls" "Controls1 \phantom{controls}"  "Controls2 \phantom{controls}" "Controls3 \phantom{controls}" "Controls4 \phantom{controls}"  "Controls5 Municipality FE" "umean Untreated $\bar{Y}$" "N Observations") ///
sfmt(%9.3f %9.3f %9.3f %9.3f  %9.3f  %9.3f  %9.3f %9.0fc) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" "`numbers'" "`emptyrow'") ///
refcat(treated "", nolabel below) title("Average Treatment Effect - Logit Model") nonotes replace

****************************************************************************************************************************************


*************************************************
*****TABLE 4
*************************************************


eststo clear

label variable treated "Treated"


eststo pooled: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)

estadd local controls "Yes"
estimates store pooled

qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: pooled

qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated1!=., cluster(kunta19)

*Store coefficient, variance and degrees of freedom for group difference calulation
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated2!=., cluster(kunta19)

*Store coefficient, variance and degrees of freedom for group difference calulation
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

*Calculate group difference
scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo neutral: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated1!=., cluster(kunta19)
mystars diffe stde df
estadd local label1 "Neutral"
estadd local label2 "- Expressive"
estadd local controls "Yes"
estimates store neutral
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: neutral

qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated2!=., cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated3!=., cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo expressive: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated2!=., cluster(kunta19)

mystars diffe stde df
estadd local label1 "Expressive"
estadd local label2 "- Informative"
estadd local controls "Yes"
estimates store expressive
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: expressive


qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated3!=., cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated1!=., cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo informative: reg voted22 treated molincome female age foreign i.moses1d firstvote i.mohighschool if treated3!=., cluster(kunta19)

mystars diffe stde df
estadd local label1 "Informative"
estadd local label2 "- Neutral"
estadd local controls "Yes"
estimates store informative
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: informative

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"Treatment: & Pooled & "Neutral" & "Expressive" & "Informative"\\ "'
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treated*) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" `"`titles1'"' "`numbers'" "`emptyrow'") ///
refcat(treated "", nolabel below) title("Different Treatments") nonotes replace

*************************************************
*****TABLE 5
*************************************************

label variable treatedf "Treated in HH"

eststo clear
eststo M1: reg voted22 treatedf, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M1
eststo M2: reg voted22 treatedf molincome female age foreign, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income"
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M2
eststo M3:  reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M3
eststo M4:  reg voted22 treatedf i.kunta19, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M4
eststo M5:  reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool i.kunta19, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M5
local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local numbers "& (1) & (2) & (3) & (4) & (5) \\ \hline"
local emptyrow "& & & & &  \\ "
local line "& & & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("Controls Controls" "Controls1 \phantom{controls}"  "Controls2 \phantom{controls}" "Controls3 \phantom{controls}" "Controls4 \phantom{controls}"  "Controls5 Municipality FE" "umean Untreated $\bar{Y}$" "N Observations") ///
sfmt(%9.3f %9.3f %9.3f %9.3f  %9.3f  %9.3f  %9.3f %9.0fc) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" "`numbers'" "`emptyrow'") ///
refcat(treatedf "", nolabel below) title("Spillovers - Average Treatment Effect") nonotes replace

*************************************************
*****TABLE A2
*************************************************

eststo clear
eststo M1: logit voted22 treatedf, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M1
eststo M2: logit voted22 treatedf molincome female age foreign, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income"
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M2
eststo M3:  logit voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "No"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M3
eststo M4:  logit voted22 treatedf i.kunta19, cluster(kunta19)
estadd local Controls "No"
estadd local Controls1 " "
estadd local Controls2 " "
estadd local Controls3 " "
estadd local Controls4 " "
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M4
eststo M5:  logit voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool i.kunta19, cluster(kunta19)
estadd local Controls "Female, Age, Immigrant,"
estadd local Controls1 "Ln Income,"
estadd local Controls2 "SES Background,"
estadd local Controls3 "Educational Background,"
estadd local Controls4 "First Time Eligble to Vote"
estadd local Controls5 "Yes"
mean voted22 if e(sample)==1 & treatedf==0
estadd scalar umean=r(table)[1,1]: M5
local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local numbers "& (1) & (2) & (3) & (4) & (5) \\ \hline"
local emptyrow "& & & & &  \\ "
local line "& & & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("Controls Controls" "Controls1 \phantom{controls}"  "Controls2 \phantom{controls}" "Controls3 \phantom{controls}" "Controls4 \phantom{controls}"  "Controls5 Municipality FE" "umean Untreated $\bar{Y}$" "N Observations") ///
sfmt(%9.3f %9.3f %9.3f %9.3f  %9.3f  %9.3f  %9.3f %9.0fc) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" "`numbers'" "`emptyrow'") ///
refcat(treatedf "", nolabel below) title("Spillovers Average Treatment Effect - Logit Model") nonotes replace



*************************************************
*****TABLE A10
*************************************************



eststo clear

eststo pooled: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool, cluster(kunta19)

estadd local controls "Yes"
estimates store pooled

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: pooled

qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf1!=., cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf2!=., cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo neutral: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf1!=., cluster(kunta19)
mystars diffe stde df
estadd local label1 "Neutral"
estadd local label2 "- Expressive"
estadd local controls "Yes"
estimates store neutral
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: neutral

qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf2!=., cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf3!=., cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo expressive: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf2!=., cluster(kunta19)

mystars diffe stde df
estadd local label1 "Expressive"
estadd local label2 "- Informative"
estadd local controls "Yes"
estimates store expressive
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: expressive


qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf3!=., cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf1!=., cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo informative: reg voted22 treatedf molincome female age foreign i.moses1d firstvote i.mohighschool if treatedf3!=., cluster(kunta19)

mystars diffe stde df
estadd local label1 "Informative"
estadd local label2 "- Neutral"
estadd local controls "Yes"
estimates store informative
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: informative

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"Treatment: & Pooled & "Neutral" & "Expressive" & "Informative"\\ "'
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treatedf*) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers posthead("`header'" "`emptyrow'" `"`titles1'"' "`numbers'" "`emptyrow'") ///
refcat(treatedf "", nolabel below) title("Spillovers - Different Treatments") nonotes replace


*************************************************
*****TABLE 7
*************************************************
*Panel A
*Create voting propensity groups for the direct effect sample
sum pvote_mother if voted22!=.  & treated!=. & female!=., detail
gen marginal=.
replace marginal=1 if pvote_mother>=r(p25) & pvote_mother<r(p75)
replace marginal=0 if pvote_mother<r(p25) | (pvote_mother>=r(p75) & pvote_mother!=.)

gen never=.
replace never=1 if pvote_mother<r(p25)
replace never=0 if pvote_mother>=r(p25) & pvote_mother!=.

gen always=.
replace always=1 if pvote_mother>=r(p75) & pvote_mother!=.
replace always=0 if pvote_mother<r(p75)



eststo clear

eststo all: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 25\% & 25-75\% & Top 25\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneity by Vote Propensity} ///
\begin{tabular}{l*{4}{c}}\hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace


eststo clear

*Panel B
*Create voting propensity groups for the spillover effect sample
sum pvoteold if voted22!=.  & treatedf!=. & female!=., detail
replace marginal=.
replace marginal=1 if pvoteold>=r(p25) & pvoteold<r(p75)
replace marginal=0 if pvoteold<r(p25) | (pvoteold>=r(p75) & pvoteold!=.)

replace never=.
replace never=1 if pvoteold<r(p25)
replace never=0 if pvoteold>=r(p25) & pvoteold!=.

replace always=.
replace always=1 if pvoteold>=r(p75) & pvoteold!=.
replace always=0 if pvoteold<r(p75)


eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects by HH's Members' Voting Propensity}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 

*Panel C

*Generate dummies for individual and hosuehold voting propensity groups
gen marginalfitemp=marginal if ntreatedf==1 & treated==1
replace marginalfitemp=marginal if ncontrolf==1 & treated==0
bys petu20: egen marginalfi=mean(marginalfitemp)

gen neverfitemp=never if ntreatedf==1 & treated==1
replace neverfitemp=never if ncontrolf==1 & treated==0
bys petu20: egen neverfi=mean(neverfitemp)


gen alwaysfitemp=always if ntreatedf==1 & treated==1
replace alwaysfitemp=always if ncontrolf==1 & treated==0
bys petu20: egen alwaysfi=mean(alwaysfitemp)



eststo clear

eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginalfi: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginalfi
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginalfi


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 25\% & 25-75\% & Top 25\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel C: Spillover Effects by Targeted (Young) Voter's Voting Propensity}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 





*************************************************
*****TABLE 8
*************************************************
*Panel A
*Create voting propensity groups for the direct effect sample

sum pvote_enet_mother if voted22!=. & treated!=. & female!=., detail
replace marginal=.
replace marginal=1 if pvote_enet_mother>=r(p25) & pvote_enet_mother<r(p75)
replace marginal=0 if pvote_enet_mother<r(p25) | (pvote_enet_mother>=r(p75) & pvote_enet_mother!=.)

replace never=.
replace never=1 if pvote_enet_mother<r(p25)
replace never=0 if pvote_enet_mother>=r(p25) & pvote_enet_mother!=.

replace always=.
replace always=1 if pvote_enet_mother>=r(p75) & pvote_enet_mother!=.
replace always=0 if pvote_enet_mother<r(p75)



eststo clear

eststo all: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 25\% & 25-75\% & Top 25\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneity by Vote Propensity - Elastic Net} ///
\begin{tabular}{l*{4}{c}}\hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace


eststo clear



*Panel B
*Create voting propensity groups for the spillover effect sample

sum pvoteold_enet if voted22!=.  & treatedf!=. & female!=., detail
replace marginal=.
replace marginal=1 if pvoteold_enet>=r(p25) & pvoteold_enet<r(p75)
replace marginal=0 if pvoteold_enet<r(p25) | (pvoteold_enet>=r(p75) & pvoteold_enet!=.)

replace never=.
replace never=1 if pvoteold_enet<r(p25)
replace never=0 if pvoteold_enet>=r(p25) & pvoteold_enet!=.

replace always=.
replace always=1 if pvoteold_enet>=r(p75) & pvoteold_enet!=.
replace always=0 if pvoteold_enet<r(p75)

eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects by HH's Members' Voting Propensity}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 

*Panel C

drop marginalfitemp marginalfi neverfitemp neverfi alwaysfitemp alwaysfi


gen marginalfitemp=marginal if ntreatedf==1 & treated==1
replace marginalfitemp=marginal if ncontrolf==1 & treated==0
bys petu20: egen marginalfi=mean(marginalfitemp)

gen neverfitemp=never if ntreatedf==1 & treated==1
replace neverfitemp=never if ncontrolf==1 & treated==0
bys petu20: egen neverfi=mean(neverfitemp)


gen alwaysfitemp=always if ntreatedf==1 & treated==1
replace alwaysfitemp=always if ncontrolf==1 & treated==0
bys petu20: egen alwaysfi=mean(alwaysfitemp)


eststo clear

eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginalfi: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginalfi==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginalfi
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginalfi


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if neverfi==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if alwaysfi==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 25\% & 25-75\% & Top 25\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel C: Spillover Effects by Targeted (Young) Voter's Voting Propensity}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 


*************************************************
*****TABLE 9
*************************************************
*Panel A

eststo clear




eststo clear


eststo nohighschool: reg voted22 treated molincome age i.moses1d firstvote female foreign if mohighschool==0, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store nohighschool
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: nohighschool




eststo highschool: reg voted22 treated molincome age i.moses1d firstvote female foreign if mohighschool==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars2=e(d_stars)
local sestars2=e(se_stars)
estadd local controls "Yes"
estimates store highschool
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: highschool


eststo noforeign: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool if  foreign==0, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store noforeign
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: noforeign




eststo foreign: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool  if foreign==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars1=e(d_stars)
local sestars1=e(se_stars)
estadd local controls "Yes"
estimates store foreign
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: foreign



local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 "& \multicolumn{2}{c}{Educational Background} & \multicolumn{2}{c}{Immigration Background} \\ "
local titles2 "& No High School & High School & Native & Immigrant\\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "dstars \hline Differences  & \multicolumn{2}{c}{`dstars1'} & \multicolumn{2}{c}{`dstars2'} \\ %" "sestars \phantom{sestars} & \multicolumn{2}{c}{`sestars1'} & \multicolumn{2}{c}{`sestars2'} \\ %") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneous Effects by Education and Immigration Background} ///
\begin{tabular}{l*{4}{c}} \hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace


eststo clear


eststo nohighschool: reg voted22 treatedf molincome age i.moses1d firstvote female foreign if mohighschool==0, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store nohighschool
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: nohighschool




eststo highschool: reg voted22 treatedf molincome age i.moses1d firstvote female foreign if mohighschool==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars1=e(d_stars)
local sestars1=e(se_stars)
estadd local controls "Yes"
estimates store highschool
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: highschool


eststo noforeign: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool if  foreign==0, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store noforeign
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: noforeign




eststo foreign: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool  if foreign==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars2=e(d_stars)
local sestars2=e(se_stars)
estadd local controls "Yes"
estimates store foreign
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: foreign




esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "dstars \hline Differences  & \multicolumn{2}{c}{`dstars1'} & \multicolumn{2}{c}{`dstars2'} \\ %" "sestars \phantom{sestars} & \multicolumn{2}{c}{`sestars1'} & \multicolumn{2}{c}{`sestars2'} \\ %") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 

***********************************************************************************************

eststo clear


eststo voted21: reg voted22 treated molincome age i.moses1d firstvote i.mohighschool female foreign if voted21==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store voted21
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: voted21




eststo notvoted21: reg voted22 treated molincome age i.moses1d firstvote i.mohighschool female foreign if voted21==0, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars1=e(d_stars)
local sestars1=e(se_stars)
estadd local controls "Yes"
estimates store notvoted21
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: notvoted21


eststo rural: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if  rural==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store rural
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: rural




eststo urban: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if rural==0, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars2=e(d_stars)
local sestars2=e(se_stars)
estadd local controls "Yes"
estimates store urban
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: urban



local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 "& \multicolumn{2}{c}{Educational Background} & \multicolumn{2}{c}{Immigration Background} \\ "
local titles2 "& No High School & High School & Native & Immigrant\\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

local dstars " "
local sestars " "
esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "dstars \hline Differences  & \multicolumn{2}{c}{`dstars1'} & \multicolumn{2}{c}{`dstars2'} \\ %" "sestars \phantom{sestars} & \multicolumn{2}{c}{`sestars1'} & \multicolumn{2}{c}{`sestars2'} \\ %") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneous Effects by Voting in 2021 and Municipality Type} ///
\begin{tabular}{l*{4}{c}} \hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace

*Panel B
eststo clear


eststo voted21: reg voted22 treatedf molincome age i.moses1d firstvote i.mohighschool female foreign if voted21==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store voted21
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: voted21




eststo notvoted21: reg voted22 treatedf molincome age i.moses1d firstvote i.mohighschool female foreign if voted21==0, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars1=e(d_stars)
local sestars1=e(se_stars)
estadd local controls "Yes"
estimates store notvoted21
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: notvoted21


eststo rural: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if  rural==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
estadd local controls "Yes"
estimates store rural
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: rural




eststo urban: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign  if rural==0, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])
mystars diffe stde df
local dstars2=e(d_stars)
local sestars2=e(se_stars)
estadd local controls "Yes"
estimates store urban
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: urban




esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "dstars \hline Differences  & \multicolumn{2}{c}{`dstars1'} & \multicolumn{2}{c}{`dstars2'} \\ %" "sestars \phantom{sestars} & \multicolumn{2}{c}{`sestars1'} & \multicolumn{2}{c}{`sestars2'} \\ %") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 



*************************************************
*****TABLE A3
*************************************************
*Panel A
*Create voting propensity groups for the direct effect sample

eststo clear


_pctile pvote_mother if voted22!=. & treated!=. & female!=., nquantiles(100)


replace marginal=.
replace marginal=1 if pvote_mother>=r(r33) & pvote_mother<r(r67)
replace marginal=0 if pvote_mother<r(r33) | (pvote_mother>=r(r67) & pvote_mother!=.)

replace never=.
replace never=1 if pvote_mother<r(r33)
replace never=0 if pvote_mother>=r(r33) & pvote_mother!=.

replace always=.
replace always=1 if pvote_mother>=r(r67) & pvote_mother!=.
replace always=0 if pvote_mother<r(r67)


eststo clear

eststo all: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 33\% & 33-67\% & Top 33\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "


esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneity by Thirds of Vote Propensity} ///
\begin{tabular}{l*{4}{c}}\hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace

*Panel B
*Create voting propensity groups for the spillover effect sample

eststo clear

_pctile pvoteold if voted22!=. & treatedf!=. & female!=., nquantiles(100)


replace marginal=.
replace marginal=1 if pvoteold>=r(r33) & pvoteold<r(r67)
replace marginal=0 if pvoteold<r(r33) | (pvoteold>=r(r67) & pvoteold!=.)

replace never=.
replace never=1 if pvoteold<r(r33)
replace never=0 if pvoteold>=r(r33) & pvoteold!=.

replace always=.
replace always=1 if pvoteold>=r(r67) & pvoteold!=.
replace always=0 if pvoteold<r(r67)



eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 

*************************************************
*****TABLE A4
*************************************************
*Panel A
*Create voting propensity groups for the direct effect sample



_pctile pvote_enet_mother if voted22!=.  & treated!=. & female!=., nquantiles(100)


replace marginal=.
replace marginal=1 if pvote_enet_mother>=r(r33) & pvote_enet_mother<r(r67)
replace marginal=0 if pvote_enet_mother<r(r33) | (pvote_enet_mother>=r(r67) & pvote_enet_mother!=.)

replace never=.
replace never=1 if pvote_enet_mother<r(r33)
replace never=0 if pvote_enet_mother>=r(r33) & pvote_enet_mother!=.

replace always=.
replace always=1 if pvote_enet_mother>=r(r67) & pvote_enet_mother!=.
replace always=0 if pvote_enet_mother<r(r67)



eststo clear

eststo all: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treated molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treated==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high

local header "& \multicolumn{4}{c}{Outcome: Voted} \\"
local titles1 `"& All & "Low Propensity" & "Marginal Voters" & "High Propensity"\\ "'
local titles2 "& & Bottom 33\% & 33-67\% & Top 33\% \\"
local numbers "& (1) & (2) & (3) & (4) \\ \hline"
local emptyrow "& & & &  \\ "
local line "& & & & \hline \\ "

esttab, keep (treated) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prehead(\begin{table}[htbp]\centering ///
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
\caption{Heterogeneity by Thirds of Vote Propensity - Elastic Net} ///
\begin{tabular}{l*{4}{c}}\hline\hline) posthead("`header'" "`emptyrow'" `"`titles1'"' "`titles2'" "`numbers'" \\ \multicolumn{4}{c}{\textbf{Panel A: Direct Effects}} \\ "`emptyrow'")  ///
refcat(treated "", nolabel below) postfoot(\hline) fragment nonotes replace


*Panel B
*Create voting propensity groups for the spillover effect sample

eststo clear



_pctile pvoteold_enet if voted22!=.  & treatedf!=. & female!=., nquantiles(100)


replace marginal=.
replace marginal=1 if pvoteold_enet>=r(r33) & pvoteold_enet<r(r67)
replace marginal=0 if pvoteold_enet<r(r33) | (pvoteold_enet>=r(r67) & pvoteold_enet!=.)

replace never=.
replace never=1 if pvoteold_enet<r(r33)
replace never=0 if pvoteold_enet>=r(r33) & pvoteold_enet!=.

replace always=.
replace always=1 if pvoteold_enet>=r(r67) & pvoteold_enet!=.
replace always=0 if pvoteold_enet<r(r67)


eststo all: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal!=., cluster(kunta19)

estadd local controls "Yes"
estimates store all

qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: all

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)
qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)

matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo low: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store low
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: low

qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo marginal: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if marginal==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "Marginal"
estadd local label2 "- High"
estadd local controls "Yes"
estimates store marginal
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: marginal


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)
matrix Brep1=e(b)
matrix Vrep1=e(V)
scalar df1=e(df_r)


qui: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if never==1, cluster(kunta19)
matrix Brep2=e(b)
matrix Vrep2=e(V)
scalar df2=e(df_r)

scalar df=df1+df2

scalar diffe=Brep1[1,1]-Brep2[1,1]
scalar stde=sqrt(Vrep1[1,1]+Vrep2[1,1])

eststo high: reg voted22 treatedf molincome female age i.moses1d firstvote i.mohighschool foreign if always==1, cluster(kunta19)

mystars diffe stde df
estadd local label1 "High"
estadd local label2 "- Low"
estadd local controls "Yes"
estimates store high
qui: mean voted22 if treatedf==0 & e(sample)==1
estadd scalar umean=r(table)[1,1]: high








esttab, keep (treatedf) noobs label se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
scalars("controls Controls " "umean Untreated $\bar{Y}$" "N Observations" "label1 \hline" "label2 \phantom{label2}" "d_stars Differences" "se_stars \phantom{se}") ///
sfmt(%9.3f %9.3f %9.0fc %9.3f) mlabels(none) nonumbers prefoot(\hline)  posthead("`emptyrow'" \multicolumn{4}{c}{\textbf{Panel B: Spillover Effects}} \\ "`emptyrow'")  ///
refcat(treatedf "", nolabel below) postfoot(\hline\hline \\ \end{tabular} \\ \end{table}) fragment append nonotes 




